package com.qf.smartplatform.service.impl;

import com.qf.smartplatform.mapper.OnlineUserMapper;
import com.qf.smartplatform.pojo.SysUserOnline;
import com.qf.smartplatform.service.OnlineUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
@Transactional
public class OnlineUserServiceImpl implements OnlineUserService {
    private OnlineUserMapper onlineUserMapper;
    @Autowired
    public void setOnlineUserMapper(OnlineUserMapper onlineUserMapper) {
        this.onlineUserMapper = onlineUserMapper;
    }

    @Override
    public void addOnlineData(SysUserOnline sysUserOnline) {
        String loginName = onlineUserMapper.dataExist(sysUserOnline.getLoginName());
        if (StringUtils.hasText(loginName)){
            onlineUserMapper.updateOnlineData(sysUserOnline);
        }else{
            onlineUserMapper.addOnlineData(sysUserOnline);
        }

    }
}
